package com.daohang361.imqq.service;

import java.io.IOException;

import com.daohang361.imqq.Asycore.AsyProtocolQQ;
import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.ServerContex.SessionContex;

/** 
 * @author naner E-mail:likun3344@163.com 
 * @create time：2011-4-12 下午04:14:51 
 */
public class LoginService implements InterfaceService,Runnable {
	private QQUser user = null;
	
	
	public  boolean login(QQUser user)
	{
		try {
			this.user=user;
			Thread thread = new Thread(this);
			thread.start();
		} catch (Exception e) {
			// TODO: handle exception
		}
		return true;
	}

	@Override
	public void run() {
		try {
			new AsyProtocolQQ(user);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	public QQUser getUser() {
		return user;
	}

	public void setUser(QQUser user) {
		this.user = user;
	}

	public static boolean getLoginState(int qqNumber) {
		// TODO Auto-generated method stub
		return SessionContex.getQQUser(qqNumber).isLogin();
	}

	@Override
	public Object doService(Object... o) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object invoke(Object... o) {
		// TODO Auto-generated method stub
		return null;
	}
	
}
